<template>
  <!-- <button @click="send">发送</button> -->
       <iframe id="myIframe" src="http://ts.aipocket-nas.igrsservice.com/#/" width="100%" height="100%"> </iframe>
<!--       <iframe id="myIframe" :src="frameUrl" width="100%" height="100%"> </iframe>-->
<!--  <iframe id="myIframe" src="http://localhost:8080/#/" width="100%" height="100%"> </iframe>-->
</template>

<script setup>
import { ref, onMounted,computed } from "vue";
import { useRouter } from "vue-router";
import {usePortStore} from "@/stores/index.js";
const { setPort,setUrl,baseURL } = usePortStore()
const router = useRouter();
const frameUrl = computed(()=>{
  return "http://" + usePortStore().baseURL + ":91";
})
const initiframe = async () => {
  //这里写登录 获取到数据传到下面的postMessage的data
  const iframe = document.getElementById('myIframe');
  iframe.onload = function () {
    iframe.contentWindow.postMessage({ message: 'open' }, '*');

  }
  window.addEventListener('message', function (event) {
    console.log('收到来自子窗口的消息：', event.data);
    if (event.data.message === 'back') {
      router.push('/knowledge')
    }
  }, false);
}
onMounted(async () => {
  initiframe()

})
</script>

<style lang="scss" scoped></style>
